package org.apache.james.mime4j.decoder;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class QuotedPrintableOutputStream extends FilterOutputStream
{
  private boolean closed = false;
  private QuotedPrintableEncoder encoder;

  public QuotedPrintableOutputStream(OutputStream paramOutputStream, boolean paramBoolean)
  {
    super(paramOutputStream);
    this.encoder = new QuotedPrintableEncoder(1024, paramBoolean);
    this.encoder.initEncoding(paramOutputStream);
  }

  // ERROR //
  public void close()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 15	org/apache/james/mime4j/decoder/QuotedPrintableOutputStream:closed	Z
    //   4: ifeq +4 -> 8
    //   7: return
    //   8: aload_0
    //   9: getfield 22	org/apache/james/mime4j/decoder/QuotedPrintableOutputStream:encoder	Lorg/apache/james/mime4j/decoder/QuotedPrintableEncoder;
    //   12: invokevirtual 32	org/apache/james/mime4j/decoder/QuotedPrintableEncoder:completeEncoding	()V
    //   15: aload_0
    //   16: iconst_1
    //   17: putfield 15	org/apache/james/mime4j/decoder/QuotedPrintableOutputStream:closed	Z
    //   20: goto -13 -> 7
    //   23: astore_1
    //   24: aload_0
    //   25: iconst_1
    //   26: putfield 15	org/apache/james/mime4j/decoder/QuotedPrintableOutputStream:closed	Z
    //   29: aload_1
    //   30: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   8	15	23	finally
  }

  public void flush()
    throws IOException
  {
    this.encoder.flushOutput();
  }

  public void write(int paramInt)
    throws IOException
  {
    byte[] arrayOfByte = new byte[1];
    arrayOfByte[0] = (byte)paramInt;
    write(arrayOfByte, 0, 1);
  }

  public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    if (this.closed)
      throw new IOException("QuotedPrintableOutputStream has been closed");
    this.encoder.encodeChunk(paramArrayOfByte, paramInt1, paramInt2);
  }
}